<?$this->_extends("_layouts/main_layout");?>

<?$this->_block("contents");?>
<script language="javascript">
function check_gauth(t) {
	$(t).parent().parent().nextUntil('.atabl').find(':checkbox').prop('checked', t.checked);
}
$(function(){
	$('#form_auth').submit(function(){
		var verify_msg = '';
		verify_msg = '您确定要修改本用户的权限吗？';
		if(confirm(verify_msg)){
			return true;	
		}else{
			return false;	
		}
	});
});
</script>
<style type="text/css">
#table_auth .authlbl {text-align:left;color:red;font-weight:bold;padding-left:15px;}
</style>
<?php echo $alert;?>
<form class="fsimple" id="form_auth" name="form_auth" action="" method="post" enctype="multipart/form-data" >
<table id="table_auth" class="list_table" width="100%" cellpadding="0" cellspacing="0">
	
	<tr>
		<th width="40%">功能模块</th>
		<th width="15%">查看 <input type="checkbox" id="cha" name="cha" ></th>
		<th width="15%">新增  <input type="checkbox" id="zeng" name="zeng" ></th>
		<th width="15%">修改 <input type="checkbox" id="gai" name="gai" ></th>
		<th width="15%">删除 <input type="checkbox" id="shan" name="shan" ></th>
	</tr>
	<?php //dump($all_perms);die;?>
<?foreach ($all_perms as $group) {?>
    <?foreach ($group as $k=>$module) {?>
   <?php //dump($k);die;?>
        <?
        if ($k == '_label') {
//        /dump($k);die;
        //if (isset($module['baselevel']) && !in_array($admin->level,$module['baselevel'])) continue;
        //if (isset($module['levels']) && !in_array($admin->level, $module['levels'])) continue;
        
        ?>
		<tr class="atabl">
			<td colspan="5" class="authlbl"><?php echo $module;?><input type="checkbox" onclick="check_gauth(this)" /></td>
		</tr>
		<?php continue;}?>
        <tr>
            <td>
            <?=$module['name']?>
           
            </td>
            <?for ($i=1; $i<=4; $i++) {?>
            	
            <td>
            
            <?php
            //dump($module['perms']);die;
			if(is_array($module['perms'])){
            if (in_array($i, $module['perms'])) {
            	//if($user_isadmin==1 ||!empty($myperms[$k]) ){
            		//if($user_isadmin==1 || in_array($i,$myperms[$k])){
                	$checked = '';
					//print_r($myData['perms']);
					//echo '<br>'.$k;
					if($myData['perms']){
						if(array_key_exists($k,$myData['perms'])){
							if(in_array($i,$myData['perms'][$k])){
								$checked='checked';
							}
						}
					}
            ?>       
            <input type="checkbox" name="perms[<?=$k?>][]" id="perms[<?=$k?>][]" value="<?=$i?>" <?php echo $checked;?>/>
         	
            <?php
            		//}
            	//}
            }
			}
            ?>
           
            
            
            </td>
            <?}?>
        </tr>
    <?}?>
    <tr>
        <td colspan="5">&nbsp;</td>
    </tr>
<?}
?>
</table><br>
<?php //if($isadmin!=1){?>
<input type="submit" class="btn" value="保存" />
<?php //}?>
<input type="button" class="btn" value="返回" onclick="history.back()" /><br />
</form>

 <script type="text/javascript">
               $("#cha").click(function(){
            	   $("#table_auth td:nth-child(2) :checkbox").prop("checked",this.checked);
                   });
               $("#zeng").click(function(){
            	   $("#table_auth td:nth-child(3) :checkbox").prop("checked",this.checked);
                   })
            	$("#shan").click(function(){
            		$("#table_auth td:nth-child(5) :checkbox").prop("checked",this.checked);
                	})
            $("#gai").click(function(){
            		$("#table_auth td:nth-child(4) :checkbox").prop("checked",this.checked);
                	});				            	
 </script>

<?$this->_endblock();?>
